package intensivecomp.util;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class CustomerFileSplit extends FileSplit{
    String id;

    public CustomerFileSplit(){

    }

    public CustomerFileSplit(Path file, long start, long length, String[] hosts) {
        super(file, start, length, hosts);
        String path = file.getParent().getParent().getName();
        this.id = path;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void write(DataOutput out) throws IOException {
       super.write(out);
        Text.writeString(out, this.id);
    }

    public void readFields(DataInput in) throws IOException {
        super.readFields(in);
        this.id = Text.readString(in);
    }
}
